package com.fs.m.server.function;

import com.fs.m.server.domain.RequestContext;
import com.fs.m.server.function.test.*;

import java.util.HashMap;
import java.util.Map;

public class FunctionManager {

    private static Map<String, Function> functionMap;

    private static Map<String, Function> testFunctionMap;

    static {
        testFunctionMap = new HashMap<String, Function>();
        testFunctionMap.put("version", new VersionFunction1());
        testFunctionMap.put("device", new DeviceFunction1());
        testFunctionMap.put("index", new IndexFunction1());
        testFunctionMap.put("categoryList", new CategoryListFunction1());
        testFunctionMap.put("hotword", new HotwordFunction1());
        testFunctionMap.put("categoryDetail", new CategoryDetailFunction1());
        testFunctionMap.put("search", new SearchFunction1());
        testFunctionMap.put("myDownload", new MyDownloadFunction1());
        testFunctionMap.put("myLike", new MyLikeFunction1());
        testFunctionMap.put("copyRight", new CopyRightFunction1());
        testFunctionMap.put("about", new AboutFunction1());
    }

    static {
        functionMap = new HashMap<String, Function>();
    }


    public static Function getFunction(String f) {
        Map otherMap = RequestContext.get().getOtherParam();
        if ("true".equals(otherMap.get("test"))) {
            return testFunctionMap.get(f);
        }
        return functionMap.get(f);
    }
}
